import React, {Component} from 'react';
import Table from '../Public/Table';

// answer: "答案"
// createTime: 1560399349000
// email: "123456761**@qq.com"
// id: 3933
// password: ""
// phone: "123****8910"
// question: "问题"
// role: 0
// updateTime: 1560399349000
// username: "AAAA76120"

class UserTable extends Component {
	constructor(props) {
		super(props);
		this.state = {
			columns: [
				{
					title: 'ID',
					props: 'id'
				},
				{
					title: '用户名',
					props: 'username',
				},
				{
					title: '邮箱',
					props: 'email'
				},
				{
					title: '电话',
					props: 'phone'
				},
				{
					title: '注册时间',
					render: data => <span>{this.formatDate(data.createTime)}</span>
				}
			]
		}
	}

	formatDate(value) {
		let date = new Date(value);
		return date.toLocaleString();
	}

	render() {
		return (
			<div>
				<Table columns={this.state.columns} data={this.props.data}/>
			</div>
		);
	}
}

export default UserTable;